<?php 
	require_once("utils.php");
	require_once("obj/session.php");
	require_once("obj/user.php");
	require_once("obj/taskinfo.php");
	
	$taskid = Utils::getTaskIdFromURL();
	$tasks = TaskInfo::getByUserId($session->UserId);
?>
<a href="<?php echo Utils::makeTaskDetailUrl(0); ?>">New</a>
<table class="datatable" width="100%" cellpadding="5" cellspacing="0">
<tr><th>Name</th><th>Description</th><th>Priority</th><th>Project</td><th>Assigned To</th><th>Created</th><th>Modified</th><th>&nbsp;</th></tr>
<?php
	$ix = 0;
	foreach($tasks as $t){
		$i = $t->TaskId; 
		$n = $t->Name;
		$d = $t->Description;
		$tp = $t->TaskPriorityName;
		$pn = $t->ProjectName;
		$ae = $t->AssignedToEmail;
		$c = $t->Created;
		$m = $t->Modified;
		$u = Utils::makeTaskDetailUrl($i);
		$tm = Utils::makeTaskTimeUrl($i);
		$cs = $ix % 2 == 0 ? "row" : "altrow";
		$el = "";
		if($role != "User") { 
			$el = "<a href=\"$u\">Edit</a>&nbsp;|&nbsp;";
		}
		echo "<tr class=\"$cs\"><td>$n</td><td>$d</td><td>$tp</td><td>$pn</td><td>$ae</td><td>$c</td><td>$m</td><td>$el<a href=\"$tm\">Time</a></td></tr>";
		$ix++;		
	}
?>
</table>
<?php echo count($tasks)." rows"; ?>